package com.xique.job.controller;

import com.xique.job.task.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 定时任务接口测试
 *
 * @author WLD
 */
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/jobTest")
public class SysJobTestController {

    private final IndexTask indexTask;

    private final ParkStatisticsIncomeTask parkStatisticsIncomeTask;

    private final ParkStatisticsInOutTask parkStatisticsInOutTask;

    private final BlackCarTask removeBlackCarTask;

    private final DelInOutTask delInOutTask;

    private final IcbcBillFileDownloadTask icbcBillFileDownloadTask;

    private final DeleteOnTask deleteOnTask;

    /**
     * 更新首页统计缓存
     */
    @PostMapping(value = "/updateStatisticsCache")
    public void updateStatisticsCache() {
        indexTask.updateStatisticsCache();
    }

    /**
     * 昨日收入统计
     */
    @PostMapping(value = "/yesterdayStatisticsIncome")
    public void yesterdayStatisticsIncome() {
        parkStatisticsIncomeTask.yesterdayStatisticsIncome();
    }

    /**
     * 昨日车次统计
     */
    @PostMapping(value = "/yesterdayStatisticsInOut")
    public void yesterdayStatisticsInOut() {
        parkStatisticsInOutTask.yesterdayStatisticsInOut();
    }

    /**
     * 1.删除超过了有效期的黑名单车辆
     * 2.下发到了启用日期的黑名单车辆
     */
    @PostMapping(value = "/handleBlackExpire")
    public void handleBlackExpire() {
        removeBlackCarTask.handleBlackExpire();
    }

    /**
     * 删除超过了有效期的黑名单车辆
     */
    @DeleteMapping(value = "/removeBlackExpire")
    public void removeBlackExpire() {
        removeBlackCarTask.removeBlackExpire();
    }

    /**
     * 下发到了启用日期的黑名单车辆
     */
    @PostMapping(value = "/downEnableBlackCar")
    public void downEnableBlackCar() {
        removeBlackCarTask.downEnableBlackCar();
    }

    /**
     * 定时删除进出记录
     */
    @PostMapping(value = "/delete")
    public void exportAndDelete() {
        delInOutTask.delete();
    }

    /**
     * 结算对账单下载 / 清分对账单下载
     */
    @PostMapping("/billFileDownloadTask")
    public void billFileDownloadTask() {
        icbcBillFileDownloadTask.billFileDownloadTask();
    }

    /**
     * 定时删除在场记录
     */
    @PostMapping("/timingDelete")
    public void timingDelete() {
        deleteOnTask.timingDelete();
    }

}
